package com.slwish.xty.ui.activity;

import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.util.Preconditions;
import com.orhanobut.logger.Logger;
import com.slwish.common.base.PresenterToolbarActivity;
import com.slwish.common.base.ToolbarActivity;
import com.slwish.xty.R;

import butterknife.BindView;

public class TestActivity extends ToolbarActivity {
    @BindView(R.id.iv)
    ImageView IV;


    @Override
    protected int getLayoutId() {
        return R.layout.act_test;
    }

    @Override
    protected void initWidget() {
        super.initWidget();
//        RequestOptions options = RequestOptions.centerInsideTransform()
//                .placeholder(R.mipmap.touxiang88)
//                .error(R.mipmap.touxiang88);
        RequestOptions options = new RequestOptions()
                .centerCrop()
                //.placeholder(R.mipmap.ic_launcher_round)
                .error(android.R.drawable.stat_notify_error)
                .priority(Priority.HIGH)
                //.skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC);
//        Glide.with(this).load(R.drawable.unnamed).apply(options).into(IV);
        Glide.with(this)
                .load("https://www.nidong.com/plangift.webp")
//                .thumbnail(Glide.with(this).load("https://www.nidong.com/plangift.webp"))
                .listener(new RequestListener<Drawable>() {
                    @Override
                    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                        Logger.e("onLoadFailed --->" +e);
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                        Logger.e("onResourceReady---> " + resource);
                        return false;
                    }
                })
                .apply(options)
                .into(IV);
    }
}
